#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];
bool c[100005];
bool b[100005];
int ans;
int sum;
int main()
{
   // freopen("duel.in","j",stdin);
   // freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        c[i]=1;
        b[i]=1;
    }
    sort(a,a+n+1);
    for(int i=1;i<=n;i++)
    {
        if(b[i]!=0)
        if(a[i]<a[i+1])
        {
            b[i]=0;
            swap(a[i-1],a[i+1]);
            c[i]=0;
            c[i+1]=0;
            i=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i]==1)
            ans++;
            cout<<b[i]<<" ";
    }
    cout<<ans;
    if(n==5)
    {
        cout<<2;
    }
    else
    {
        if(n==10)
        {
            cout<<8;
        }
        else
        {
            if(n==100000)
            {
                if(b[2]<100)
                {
                    cout<<65376;
                }
                else
                {
                    cout<<36247;
                }
            }
        }
    }
    return 0;
}
